# Maintainer: Jiachen Yang <farseerfc@gmail.com>
# AUR Maintainer: Hyacinthe Cartiaux <hyacinthe.cartiaux@free.fr>
# Contributor: Bartosz Chmura <chmurli@gmail.com>
# Contributor: Alessio Sergi <asergi at archlinux dot us>
# Contributor: alfplayer
# Contributor: menta

_pkgname=ReText
pkgname=retext
pkgver=8.0.1
pkgrel=1
pkgdesc="A simple editor for Markdown and ReStructuredText markup languages"
arch=('any')
url="https://github.com/retext-project/retext"
license=('GPL3')
# for desktop integration: 'shared-mime-info' 'xdg-utils' 'desktop-file-utils'
# for toolbar icons (see http://sourceforge.net/p/retext/tickets/44/): 'gconf'
depends=('python-pyqt6' 'python-markups>=2.0.0' 'shared-mime-info' 'xdg-utils' 'python-docutils'
         'desktop-file-utils' 'hicolor-icon-theme' 'python-markdown' 'python-pygments' 'python-chardet')
makedepends=('imagemagick' 'qt6-tools' 'python-setuptools')
checkdepends=('xorg-server-xvfb' 'python-chardet' 'python-docutils')
optdepends=('python-pyqt6-webengine: for WebEngine preview'
            'python-pyenchant: for spell checking support')
source=("https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.tar.gz"
        "x-retext-rst.xml")
sha256sums=('8c3a2247d381b40b14cb4a63a184a62e35f16d31699aedfbe9c294a043ec0d96'
            '6fef80cccb14813d9cc74810c397a6cd7831d1ca243536759a47c6e8b6cc977a')
validpgpkeys=('F24299FF1BBC9018B906A4CB6026936D2F1C8AE0') # Dmitry Shachnev <mitya57@debian.org>

build () {
    cd "$srcdir/${_pkgname}-${pkgver}"
    python3 setup.py build
}

check() {
    cd "$srcdir/${_pkgname}-${pkgver}"
    xvfb-run python3 setup.py test
}

package () {
    cd "$srcdir/${_pkgname}-${pkgver}"
    python3 setup.py install --root="$pkgdir" -O1

    # create /usr/share/* dirs
    _SHAREDIR="$pkgdir/usr/share"
    install -d -m 755 "$_SHAREDIR"/{applications,mime/packages}

    # install icons
    _ICONSDIR="$_SHAREDIR/icons/hicolor"
    for size in 16 22 24 32 48 128; do
      install -d -m 755 "$_ICONSDIR"/${size}x${size}/apps
      convert -resize $size +set date:create +set date:modify ReText/icons/$pkgname.png "$_ICONSDIR"/${size}x${size}/apps/$pkgname.png
    done
    install -d -m 755 $_ICONSDIR/scalable/apps
    install -m 644 ReText/icons/$pkgname.svg "$_ICONSDIR"/scalable/apps/$pkgname.svg

    # install mime files
    install -m 644 "$srcdir"/x-retext-rst.xml "$_SHAREDIR"/mime/packages/
}

# vim:set ts=2 sw=2 et:
